package com.example.sqlitedemo;

import android.app.Activity;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.webkit.WebView;

public class MainActivity extends Activity {

	private static final String tag = "DataBaseHelper";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.web_view);
		
		DataCalendarHelper calendar = new DataCalendarHelper(this);
		
		calendar.DataProcessing();
		
//		calendar.getReadableDatabase();
		
//		DataBaseHelper dbHelper = new DataBaseHelper(this);
//		
		SQLiteDatabase db = calendar.getReadableDatabase();
		
		String query = "SELECT * FROM " + DataCalendarHelper.UserTable.NAME +
						" WHERE " + DataCalendarHelper.UserTable.COL_NAME + " = \"aug01.xml\"";
		Log.d(tag, query);
		Cursor cursor = db.rawQuery(query, null);
		
		cursor.moveToFirst();
		
		WebView webView = (WebView)findViewById(R.id.web_view);
		
		String str = cursor.getString(2);
		//str.replace("\n", "<br>");
		
		webView.loadData(str, "text/html", "utf-8");
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

}
